home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / lexcmp.c < prev    next >
Text File  |  1980-01-01  |  2KB  |  52 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. /*
  3. ** lexcmp(s, t) - Return a number <0, 0, or>0 
  4. **                as s is <, =, or > t.
  5. */
  6.  
  7. /*
  8. ** lexorder(c1, c2)
  9. **
  10. ** Return a negative, zero, or positive number if
  11. ** c1 is less than, equal to, or greater than c2,
  12. ** based on a lexicographical (dictionary order)
  13. ** colating sequence.
  14. **
  15. */
  16. static char Ulex[128] = {
  17.      /**** NUL - / ****/
  18.        0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
  19.       10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
  20.       20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
  21.       30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
  22.       40, 41, 42, 43, 44, 45, 46, 47,
  23.      /**** 0-9 ****/
  24.       65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
  25.      /**** : ; < = > ? @ ****/
  26.       48, 49, 50, 51, 52, 53, 54,
  27.      /**** A-Z ****/
  28.       75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
  29.       88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,
  30.      /**** [ \ ] ^ U ` ****/
  31.       55, 56, 57, 58, 59, 60,
  32.      /**** a-z ****/
  33.       75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
  34.       88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,100,
  35.      /**** { | } ~ ****/
  36.       61, 62, 63, 64,
  37.      /**** DEL ****/
  38.      101
  39.      };
  40.  
  41. lexcmp(s, t) char *s, *t; {
  42.   while(lexorder(*s, *t) == 0)
  43.     if(*s++) ++t;
  44.     else return(0);
  45.   return (lexorder(*s, *t));
  46.   }
  47.  
  48.  
  49. lexorder(c1, c2) char c1, c2; {
  50.   return(Ulex[c1] - Ulex[c2]);
  51.   }
  52.